package com.example.service.impl;

import com.example.mapper.productDataCheckListMapp;
import com.example.pojo.productDataCheckListPojo;
import com.example.service.productDataCheckListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Map;

@Service
public class productDataCheckListImpl implements productDataCheckListService {
    @Autowired
    private productDataCheckListMapp productDataCheckListMapp;

    //查询AI品质门检测数据的数据表中的所有内容
    public List<productDataCheckListPojo> queryAll() {
        List<productDataCheckListPojo> pojoList = productDataCheckListMapp.queryAll();
        return pojoList;
    }

    //查询一条数据,根据筛选的日期值进行筛选数据并返回（利用map功能）
    public List<productDataCheckListPojo> queryByTimeScope(Map<String, Object> map) {
        String fieldName = (String) map.get("fieldName");
        String minVal = (String) map.get("minVal");
        String maxVal = (String) map.get("maxVal");
        // 定义日期时间格式化器
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        // 将字符串转换为 LocalDateTime
        LocalDateTime minDateTime = LocalDateTime.parse(minVal, formatter);
        LocalDateTime maxDateTime = LocalDateTime.parse(maxVal, formatter);
        //传递参数，调用mapp层执行SQL查询
        List<productDataCheckListPojo> pojos = productDataCheckListMapp.queryByTimeScope(fieldName,minDateTime,maxDateTime);

        return pojos;
    }


}
